package org.neuedu.vblogserver.controller;

import com.github.pagehelper.PageInfo;
import org.neuedu.vblogserver.bean.RespBean;
import org.neuedu.vblogserver.bean.UserBean;
import org.neuedu.vblogserver.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping
public class UserConreoller {
    @Autowired
    UserService userService;
    @GetMapping("/getUsers")
    public PageInfo getUsers(String serchKeyWord, @RequestParam(value = "pageNum",defaultValue = "1") int pageNum, @RequestParam(value = "pageSize",defaultValue = "5") int pageSize) {
        return userService.getUsers(serchKeyWord,pageNum,pageSize);
    }

    @PutMapping("/isEnabled")
    public RespBean isEnabled(@RequestBody UserBean userBean) {
        return userService.isEnabled(userBean);
    }

    @PutMapping("/isLocked")
    public RespBean isLocked(@RequestBody UserBean userBean) {
        return userService.isLocked(userBean);
    }
    @DeleteMapping("/delUserRole/{uid}/{rid}")
    public RespBean delUserRole(@PathVariable String uid,@PathVariable String rid){
        return userService.delUserRole(uid,rid);
    }

}
